// alert(123)

$(function () {
	  
	  $.ajax({
		  
		  type:"post",
		  url:"/v1/website/article-list",
		  dataType:"json",
		  success:function (data){
			console.log(data)
			
			 if(data.code == 200) {
				 
				var list = data.data;
				var rateLsit1 = list.article1;
				var rateLsit2 = list.article2;
				// alert(rateLsit1)
				var htmlRight1 = '';
				var htmlRight2 = '';
				// alert(rateLsit1[0].title)
				for (var i = 0; i < rateLsit1.length; i++ ){

         
					htmlRight1 += '<li><a href="strategyDetail.html?id='+ rateLsit1[i].id +'" target="_blank">' + rateLsit1[i].key + rateLsit1[i].title  + '</a></li>'
				}
				 
			    for (var i = 0; i < rateLsit2.length; i++ ){
			 	  htmlRight2 += '<li><a href="strategyDetail.html?id='+ rateLsit2[i].id +'" target="_blank">' + rateLsit2[i].key + rateLsit2[i].title  + '</a></li>'
			    }
				$('#articalListBot1').html(htmlRight1);
				$('#articalListBot2').html(htmlRight2);
				
				// 选项卡
				var hotList = list.product;
//				alert(hotList.length);
				var hotPic = '';
				var hotKFlogo1 = '';
				var hotKFlogo2 = '';
				var hotKFlogo3 = '';
				var hotKFlogo4 = '';
				var hotRate = '';
			  var rateLabel = '';
			  var hotUL = '';
			  var div2Bottom = '';
				for(var i=0;i<hotList.length;i++){
				//				如果没有客服图片使用默认logo
				  var kefuImg1 = hotList[i].custom1_img;
					var kefuImg2 = hotList[i].custom2_img;
					var kefuImg3 = hotList[i].custom3_img;
					if(kefuImg1 == ""){
						kefuImg1 = "../../img/websiteImg/MRserver.png"
					}if(kefuImg2 == ""){
						kefuImg2 = "../../img/websiteImg/MRserver.png"
					}if(kefuImg3 == ""){
						kefuImg3 = "../../img/websiteImg/MRserver.png"
					}
					// 判断有无抵押
					var YNDY = hotList[i].is_mortgage;
					if(hotList[i].is_mortgage == 0){
						YNDY = "无抵押"
					}else{
						YNDY = "有抵押"
					}
					hotPic += '<li><img src="'+ hotList[i].product_logo +' " alt= " '+ hotList[i].product_logo_alt +' "/></li>'
				 	$('#hotProductLeftImg' + (i + 1)).attr("src",hotList[i].company_logo);
				  $('#hotProductLeftImg' + (i + 1)).attr("alt",hotList[i].company_logo_alt);
//				  console.log(hotList[i].product_logo_alt);
//				  console.log(hotList[i].company_logo_alt);
//				  console.log(hotList[i].company_logo);
           hotRate = '<span class="hotDiv2TopLeft1">'+ hotList[i].rate +'</span>'
           rateLabel= '<span class="hotDiv2TopLeft2">'+ hotList[i].rate_label +'</span>'
//				  console.log(hotRate)
//        console.log(rateLabel)

          hotUL = '<li><span class="slogo"><img src="../../img/websiteImg/hot1.png"/></span><span class="sW">'+ hotList[i].money +'</span></li><li><span class="slogo"><img src="../../img/websiteImg/hot2.png"/></span><span class="sW">'+ hotList[i].time_limit +'</span></li><li><span class="slogo"><img src="../../img/websiteImg/hot3.png"/></span><span class="sW">'+ YNDY +'</span><span class="sW">'+ hotList[i].desc_mortgage +'</span></li>'
           
//       console.log(hotUL)
         div2Bottom = '<span class="hotDiv2BottomLeftImg"><img src="'+ hotList[i].product_logo +' " alt= " '+ hotList[i].product_logo_alt +' "/></span><div class="hotDiv2BottomInfo">' + hotList[i].content + '</div>'

//        设置利率和利率标签
          $('#hotDiv2TopLeft'+ (i + 1)).html(hotRate+rateLabel);
          
//        设置详细信息
          $('#hotUL'+ (i + 1)).html(hotUL);
          
          $('#hotDiv2Bottom'+ (i + 1)).html(div2Bottom);
          
          
          //div点击跳转到相应页面

           $('#hotDivA'+ (i + 1)).attr('href','productDetail.html?id='+ hotList[i].id); 

						var hotimg = '<span><img src="'+ kefuImg1 +' " alt= " '+ hotList[0].custom1_alt +' "/></span><span><img src="'+ kefuImg2 +' " alt= " '+ hotList[0].custom2_alt +' "/></span><span><img src="'+ kefuImg3 +' " alt= " '+ hotList[0].custom3_alt +' "/></span>';
						$('#kefuLogoHot' + (i + 1)).html(hotimg)

				}
				
//        $('.hotDiv2TopLeft').html(hotRate)
//设置客服				

				// 选项卡
//设置左侧li图片
				$('.hotProductLeftImg').html(hotPic);
		   
//				设置利率
//      $('.hotDiv2TopLeft1').html(hotRate)
       
				//右侧选项卡    
		   $(document).ready(function(){
		    $(".hotProductLeftImg li").click(function(){
		        $(".hotProductLeftImg li").eq($(this).index()).addClass("cur").siblings().removeClass('cur');
		        $(".hotDiv").hide().eq($(this).index()).show();
		      });
		    });
				// 文章列表
				$('.articalListBot ul').html(htmlRight1);
				$('#articalListBot2 ul').html(htmlRight2);
				 

				 
				 
				 
			 }
		  },
		  error: function (XMLHttpRequest) {
			  if( XMLHttpRequest.status == 400)
			  {
				  location.href = "404.html";
			  }
			  else
			  {
				  location.href = "505.html";
			  }
		  }
	  })
  })
  